package hu.bme.mit.inf.expendables.entities;
	
import javax.persistence.*;
import hu.bme.mit.inf.expendables.entities.*;
import java.util.List;
import java.util.ArrayList;


@Entity
@Table(name="T_CUSTOMER")
@NamedQueries(
	{
	@NamedQuery(name=Customer.GET_CUSTOMER,query="SELECT c FROM Customer c WHERE c.userId = :custId"),
	@NamedQuery(name=Customer.GET_CUSTOMERBYUSERNAME,query="SELECT c FROM Customer c WHERE c.username = :username"),
	@NamedQuery(name=Customer.DELETE_CUSTOMER,query="DELETE FROM Customer c WHERE c.userId = :custId"),
	@NamedQuery(name=Customer.GET_OWNEDAPP,query="SELECT a FROM Customer c JOIN c.ownedApps a WHERE c.userId = :userId AND a.appMetadataId = :appMetadataId")
	})
public class Customer extends User {
	                        	
	public static final String GET_CUSTOMER = "GetCustomer";
	public static final String GET_CUSTOMERBYUSERNAME = "GetCustomerByUsername";
	public static final String DELETE_CUSTOMER = "DeleteCustomer";
	public static final String GET_OWNEDAPP = "GetOwnedApp";

	//Attributes

	//Reference to AppMetadata
	@ManyToMany(mappedBy="owners")
	private List<AppMetadata> ownedApps= new ArrayList<AppMetadata>();
	
	//Reference to Transaction
	@OneToMany(mappedBy="customer")
	private List<Transaction> transactions= new ArrayList<Transaction>();
	


	//Getters and Setters

	public List<AppMetadata> getOwnedApps(){
		return ownedApps;
	}
	
	public void setOwnedApps(List<AppMetadata> ownedApps){
		this.ownedApps = ownedApps;
	}
		
	public List<Transaction> getTransactions(){
		return transactions;
	}
	
	public void setTransactions(List<Transaction> transactions){
		this.transactions = transactions;
	}
		
}